<!--
 * @Description: 生产经营单位安全生产“三项岗位人员”持证情况汇总表
 * @Autor: cjj
 * @Date: 2023-10-09 14:36:16
 * @LastEditTime: 
-->
<template>
  <div class="TISchedule">
    <div style="padding-right: 7px;">
      <el-button type="primary" style="float:right" @click="exportWord"
        >导出Word</el-button
      >
    </div>
    <div class="mytable" style="width:800px">
      <div class="table_title">生产经营单位安全生产“三项岗位人员”持证情况汇总表</div>
      单位名称：（盖章）
      <table>
        <tr>
          <td rowspan="3">单位基本情况</td>
          <td>单位名称</td>
          <td colspan="7"></td>
          <!-- <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td> -->
        </tr>
        <tr>
          <!-- <td></td> -->
          <td>单位类型</td>
          <td colspan="7">危险化学品□ 煤矿□ 非煤矿山□ 烟花爆竹□ 金属冶炼□ 其他□</td>
          <!-- <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td> -->
        </tr>
        <tr>
          <!-- <td></td> -->
          <td>高危行业企业主要负责人</td>
          <td width="10%">{{ dataForm.listSize }}人</td>
          <td>高危行业企业安全生产管理人员</td>
          <td width="10%">{{ dataForm.listSize2 }}人</td>
          <td>特种作业人员</td>
          <td colspan="3">{{ dataForm.listSize3 }}人</td>
  
        </tr>
        <tr>
          <td colspan="9">高危行业企业主要负责人持证情况</td>
          <!-- <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td> -->
        </tr>
        <tr>
          <td>序号</td>
          <td>姓名</td>
          <td>性别</td>
          <td>行业类别</td>
          <td width="20%">证书编号</td>
          <td>初领日期</td>
          <td>有效期</td>
          <td colspan="2">发证单位</td>
        </tr>
        <tr v-for="(item, index) in list" :key="index">
          <td>{{ item.seq }}</td>
          <td>{{ item.stuName }}</td>
          <td>{{ item.gender }}</td>
          <td>{{ item.hyType }}</td>
          <td>{{ item.certNum }}</td>
          <td>{{ item.firstReceiveDate }}</td>
          <td>{{ item.endDate }}</td>
          <td colspan="2">{{ item.deliverUnit }}</td>
        </tr>
        <tr>
          <td colspan="9">高危行业企业安全生产管理人员持证情况</td>
        </tr>
        <tr>
          <td>序号</td>
          <td>姓名</td>
          <td>性别</td>
          <td>行业类别</td>
          <td>证书编号</td>
          <td>初领日期</td>
          <td>有效期</td>
          <td colspan="2">发证单位</td>
        </tr>
        <tr v-for="(item, index) in list2" :key="index">
          <td>{{ item.seq }}</td>
          <td>{{ item.stuName }}</td>
          <td>{{ item.gender }}</td>
          <td>{{ item.hyType }}</td>
          <td>{{ item.certNum }}</td>
          <td>{{ item.firstReceiveDate }}</td>
          <td>{{ item.endDate }}</td>
          <td colspan="2">{{ item.deliverUnit }}</td>
        </tr>
        <tr>
          <td colspan="9">特种作业人员持证情况</td>
          <!-- <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td> -->
        </tr>
        <tr>
          <td>序号</td>
          <td>姓名</td>
          <td>性别</td>
          <td>作业类别</td>
          <td>操作项目</td>
          <td>证书编号</td>
          <td>初领日期</td>
          <td>有效期</td>
          <td>发证单位</td>
        </tr>
        <tr v-for="(item, index) in list3" :key="index">
          <td>{{ item.seq }}</td>
          <td>{{ item.stuName }}</td>
          <td>{{ item.gender }}</td>
          <td>{{ item.hyType }}</td>
          <td>{{ item.actThing }}</td>
          <td>{{ item.certNum }}</td>
          <td>{{ item.firstReceiveDate }}</td>
          <td>{{ item.endDate }}</td>
          <td>{{ item.deliverUnit }}</td>
        </tr>
 
        <tr>
          <td >填表人（签字）：　</td>
          <td colspan="8" style="text-align:right"><input type="text" v-model="dataForm.rq" readonly="readonly"/></td>
          <!-- <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td> -->
        </tr>
        <tr>
          <td colspan="9">注：生产经营单位对安全生产“三项岗位人员”证件真伪情况进行核查。</td>
          <!-- <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td> -->
        </tr>
      </table>

      <div class="table_bottom">注：身份证复印件粘贴在本表背面。</div>
      <br/><br/><br/>
    </div>
  </div>
</template>
<script>
import request from "@/utils/request";
export default {
  name: "TISchedule",
  data() {
    return {
      loading: true,
      dataForm: {
        childrenVOList: [],
        childrenVOList2: [],
        childrenVOList3: []
      },
      list: [],
      list2: [],
      list3: []
    };
  },
  created() {},
  computed: {
    total() {
      let total = 0;
      this.list.forEach(item => {
        total += Number(item.coursewareTime);
      });
      this.dataForm.total = total;
      return total;
    }
  },
  methods: {
    init(id) {
      this.loading = true;

      request({
        url: "/api/class_archives/generateA17/" + this.$store.getters.organizeId,
        method: "get"
      }).then(res => {
        this.dataForm = res.data;
        // 创建10位数组
        this.list = Array.apply(null, { length: this.dataForm.childrenVOList.length }).map(() => {
          return { coursewareName: "", coursewareTime: "", teacherName: "" };
        });
        // 获取数据数组长度
        let lgh = this.dataForm.childrenVOList.length;
        // 替换数组
        this.list.splice(0, lgh, ...this.dataForm.childrenVOList);

        // 创建10位数组
        this.list2 = Array.apply(null, { length: this.dataForm.childrenVOList2.length }).map(() => {
          return { coursewareName: "", coursewareTime: "", teacherName: "" };
        });
        // 获取数据数组长度
        let lgh2 = this.dataForm.childrenVOList2.length;
        // 替换数组
        this.list2.splice(0, lgh2, ...this.dataForm.childrenVOList2);

        // 创建10位数组
        this.list3 = Array.apply(null, { length: this.dataForm.childrenVOList3.length }).map(() => {
          return { coursewareName: "", coursewareTime: "", teacherName: "" };
        });
        // 获取数据数组长度
        let lgh3 = this.dataForm.childrenVOList3.length;
        // 替换数组
        this.list3.splice(0, lgh3, ...this.dataForm.childrenVOList3);
        this.loading = false;
      });
    },
    exportWord() {
      this.dataForm.childrenVOList = this.list;
      for (let key in this.dataForm) {
        if (Array.isArray(this.dataForm[key])) {
          this.dataForm[key].forEach(item => {
            for (let key2 in item) {
              if (item[key2] == null) {
                item[key2] = "";
              }
            }
          });
        } else if (this.dataForm[key] == null) {
          this.dataForm[key] = "";
        }
      }
      this.dataForm.organizeId=this.$store.getters.organizeId;
      request({
        responseType: "blob",
        url: "/api/class_archives/generateA17Export",
        method: "post",
        data: this.dataForm
      }).then(res => {
        var debug = res;
        if (debug) {
          var a = document.createElement("a");
          a.download = "生产经营单位安全生产“三项岗位人员”持证情况汇总表.docx";
          a.style.display = "none";
          var blob = new Blob([debug], { type: "application/x-msdownload" });
          a.href = URL.createObjectURL(blob);
          document.body.appendChild(a);
          a.click();
          document.body.removeChild(a);
        }
      });
    }
  }
};
</script>
<style scoped lang="scss">
// 引入公共样式
@import "./TABLESTYLE.scss";
</style>
